package Demo7;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
//@Scope("prototype")
public class Person {
//    @Value("张三")
    private String name;
    public Person(){
        System.out.println("1.Person的构造方法");
    }

    public String getName() {
        return name;
    }
    @Value("张三")
    public void setName(String name) {
        System.out.println("2.setName方法");
        this.name = name;
    }
    @PostConstruct
    public void init(){
        System.out.println("3.容器已经将Person初始化,init方法被调用");
    }
    @PreDestroy
    public void preDestroy(){
        System.out.println("4.容器将Person销毁,destroy方法被调用");
    }
}
